package cn.yuanqiao.web.controller.archive.storeRoom;

import cn.yuanqiao.archive.storeRoom.domain.Boxspec;
import cn.yuanqiao.archive.storeRoom.service.IBoxspecService;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 档案盒规格Controller
 * 
 * @author xy
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/archive/boxspec")
public class BoxspecController extends BaseController
{
    @Autowired
    private IBoxspecService boxspecService;

    /**
     * 查询档案盒规格列表
     */
    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:filingBox:list')")
    @GetMapping("/list")
    public TableDataInfo list(Boxspec boxspec)
    {
        startPage();
        List<Boxspec> list = boxspecService.selectBoxspecList(boxspec);
        return getDataTable(list);
    }

    @GetMapping("/boxspecList")
    public TableDataInfo boxspecList(Boxspec boxspec)
    {
/*
        startPage();
*/
        List<Boxspec> list = boxspecService.selectBoxspecList(boxspec);
        return getDataTable(list);
    }

    /**
     * 导出档案盒规格列表
     */

/*
    @PreAuthorize("@ss.hasPermi('storeroom:boxspec:export')")
*/
    @Log(title = "档案盒规格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Boxspec boxspec)
    {
        List<Boxspec> list = boxspecService.selectBoxspecList(boxspec);
        ExcelUtil<Boxspec> util = new ExcelUtil<Boxspec>(Boxspec.class);
        util.exportExcel(response, list, "档案盒规格数据");
    }

    /**
     * 获取档案盒规格详细信息
     */
/*
    @PreAuthorize("@ss.hasPermi('storeroom:boxspec:query')")
*/
    @GetMapping(value = "/{specId}")
    public AjaxResult getInfo(@PathVariable("specId") Long specId)
    {
        return success(boxspecService.selectBoxspecBySpecId(specId));
    }

    /**
     * 新增档案盒规格
     */

    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:filingBox:add')")
    @Log(title = "档案盒规格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Boxspec boxspec)
    {
        return toAjax(boxspecService.insertBoxspec(boxspec));
    }

    /**
     * 修改档案盒规格
     */
/*
    @PreAuthorize("@ss.hasPermi('storeroom:boxspec:edit')")
*/
    @Log(title = "档案盒规格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Boxspec boxspec)
    {
        return toAjax(boxspecService.updateBoxspec(boxspec));
    }

    /**
     * 删除档案盒规格
     */

    @PreAuthorize("@ss.hasPermi('archive:warehouseManagement:filingBox:delete')")
    @Log(title = "档案盒规格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{specIds}")
    public AjaxResult remove(@PathVariable Long[] specIds)
    {
        return toAjax(boxspecService.deleteBoxspecBySpecIds(specIds));
    }
}
